package com.zhiyou100.video.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou100.video.dao.UserDao;
import com.zhiyou100.video.model.User;
import com.zhiyou100.video.service.UserService;
import com.zhiyou100.video.utils.MailUtil;
import com.zhiyou100.video.utils.VerificationCode;
@Service
public class UserServiceImpl implements UserService{
	@Autowired
	UserDao ud;
	@Override
	public void addRegister(User upe) {
		ud.addRegister(upe);
	}
	@Override
	public List<User> selectUser(DetachedCriteria dc) {
		
		return ud.selectUser(dc);
	}
	@Override
	public void updateUserProfile(User uer) {
			ud.updateUserProfile(uer);
	}
	@Override
	public User selectUserSession(User uer) {
		
		
		return ud.selectUserSession(uer);
			
	}
	@Override
	public void updateUserAvatar(User uer) {
			ud.updateUserAvatar(uer);
	}
	@Override
	public void updatePassWord(User upe) {
		ud.updatePassWord(upe);
	}
	@Override
	public void updateSendemail(User upe) {
		String vCode = VerificationCode.VCode("fsfsdfdsfgdghhjgdfgd", 4);
		try {
			MailUtil.send("1585019349@qq.com","验证码", vCode);
		} catch (Exception e) {
			e.printStackTrace();
		}
		upe.setCaptcha(vCode);
		ud.updateSendemail(upe);
	}
	@Override
	public void updateResetPwd(User uer) {
		ud.updateResetPwd(uer);
	}
	
	

}
